<!-- basic scripts -->

<!--[if !IE]> -->
<script src="__PUBLIC__/ace/js/jquery-2.1.4.min.js"></script>

<!-- <![endif]-->

<!--[if IE]>
<script src="__PUBLIC__/ace/js/jquery-1.11.3.min.js"></script>
<![endif]-->
<script type="text/javascript">
    if('ontouchstart' in document.documentElement) document.write("<script src='__PUBLIC__/ace/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
</script>
<script src="__PUBLIC__/ace/js/bootstrap.min.js"></script>

<!-- page specific plugin scripts -->

<!--[if lte IE 8]>
<script src="__PUBLIC__/ace/js/excanvas.min.js"></script>
<![endif]-->
<script src="__PUBLIC__/ace/js/jquery-ui.custom.min.js"></script>
<script src="__PUBLIC__/ace/js/jquery.ui.touch-punch.min.js"></script>
<script src="__PUBLIC__/ace/js/jquery.easypiechart.min.js"></script>
<script src="__PUBLIC__/ace/js/jquery.sparkline.index.min.js"></script>
<script src="__PUBLIC__/ace/js/jquery.flot.min.js"></script>
<script src="__PUBLIC__/ace/js/jquery.flot.pie.min.js"></script>
<script src="__PUBLIC__/ace/js/jquery.flot.resize.min.js"></script>

<!-- ace scripts -->
<script src="__PUBLIC__/ace/js/ace-elements.min.js"></script>
<script src="__PUBLIC__/ace/js/ace.min.js"></script>


<script src="__PUBLIC__/others/jquery.form.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
<script>
    $(document).ready(function () {
        $('th input[type=checkbox], td input[type=checkbox]').prop('checked', false);
        var active_class = 'active';
        $('#ListTable > thead > tr > th input[type=checkbox]').eq(0).on('click', function(){
            var th_checked = this.checked;//checkbox inside "TH" table header

            $(this).closest('table').find('tbody > tr').each(function(){
                var row = this;
                if(th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
                else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
            });
        });

        //select/deselect a row when the checkbox is checked/unchecked
        $('#ListTable').on('click', 'td input[type=checkbox]' , function(){
            var $row = $(this).closest('tr');
            if($row.is('.detail-row ')) return;
            if(this.checked) $row.addClass(active_class);
            else $row.removeClass(active_class);
        });
    });
</script>